package com.gongfutrip.trans.remoting;

import java.util.List;
import java.util.concurrent.ExecutorService;

import com.gongfutrip.trans.remoting.expception.RemotingConnectException;
import com.gongfutrip.trans.remoting.expception.RemotingSendRequestException;
import com.gongfutrip.trans.remoting.expception.RemotingTimeoutException;
import com.gongfutrip.trans.remoting.expception.RemotingTooMuchRequestException;
import com.gongfutrip.trans.remoting.protocol.RemotingCommand;

public interface RemotingClient extends RemotingService {

  public void updateNameServerAddressList(final List<String> addrs);

  public List<String> getNameServerAddressList();

  public RemotingCommand invokeSync(final String addr, final RemotingCommand request,
      final long timeoutMillis) throws InterruptedException, RemotingConnectException,
      RemotingSendRequestException, RemotingTimeoutException;

  public void invokeAsync(final String addr, final RemotingCommand request,
      final long timeoutMillis, final InvokeCallback invokeCallback)
      throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException,
      RemotingTimeoutException, RemotingSendRequestException;

  public void invokeOneway(final String addr, final RemotingCommand request,
      final long timeoutMillis) throws InterruptedException, RemotingConnectException,
      RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException;

  public void registerProcessor(final int requestCode, final NettyRequestProcessor processor,
      final ExecutorService executor);

  public boolean isChannelWriteable(final String addr);
}
